package pcd1112.test.model;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

import org.junit.Test;

public class ProvaMD5 {

	@Test
	public void test() {
		MessageDigest md;
		try {
			for (int i = 0; i < 2; i++) {
				md = MessageDigest.getInstance("MD5");
				md.reset();
				// md.update((byte)(message.getID()+rand+i));
				md.update((byte) (4 + 0.5 + i));
				byte[] digest = md.digest(); // calculate
				String x_s = "0.", y_s = "0.";
				for (int ix = 0; ix < (digest.length / 2); ix++)
					x_s += Math.abs(digest[ix]);
				for (int iy = (digest.length / 2); iy < digest.length; iy++)
					y_s += Math.abs(digest[iy]);
				Double x = Double.parseDouble(x_s); // x coordinate
				Double y = Double.parseDouble(y_s); // y coordinate
				System.out.println("X: " + x + " Y: " + y);
				/*
				 * Coordinate dest=new Coordinate(x,y); //for every i=location
				 * g, clone the original message, changing only the destination
				 * coordinates LocationClaim mex_i= new LocationClaim();
				 * mex_i.clone(message); mex_i.setDestination(dest);
				 * forw(mex_i); //complete the forwarding
				 */
			}
		} catch (NoSuchAlgorithmException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

}
